package com.jiang.core.common;

import com.jiang.core.enums.BusinessCode;
import com.jiang.core.enums.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * AppExcetion: 应用自定义异常
 * </p>
 *
 * @author jiang
 * @since 2021/6/5
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class AppException extends RuntimeException {

    private int code;
    private String message;

    private AppException(String message){
        super(message);
        this.code = 500;
        this.message = "AppException.";
    }

    public AppException(ErrorCode code){
        super(code.getDesc());
        this.code = code.getValue();
        this.message = code.getDesc();
    }

    public AppException(int code, String message){
        super(message);
        this.code = code;
        this.message = message;
    }
}